package com.desmart.renjiao.attendance;

import android.widget.TextView;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.desmart.renjiao.R;
import com.desmart.renjiao.bean.CheckRecord;

import java.util.List;

public class AttendanceRecordAdapter extends BaseMultiItemQuickAdapter<CheckRecord,BaseViewHolder>{

    public AttendanceRecordAdapter(List<CheckRecord> data) {
        super(data);
        addItemType(CheckRecord.Title_Record, R.layout.attendance_record_type_title_record);
        addItemType(CheckRecord.Title_Error, R.layout.attendance_record_type_title_error);
        addItemType(CheckRecord.Record, R.layout.attendance_record_type_record);
        addItemType(CheckRecord.Error, R.layout.attendance_record_type_record);
    }

    @Override
    protected void convert(BaseViewHolder helper, CheckRecord item) {
        switch (helper.getItemViewType()) {
            case CheckRecord.Record:
                bindRecord(helper, item);
                break;
            case CheckRecord.Error:
                bindError(helper,item);
                break;

        }
    }

    private void bindError(BaseViewHolder helper, CheckRecord item) {
        TextView tvTime = helper.itemView.findViewById(R.id.tv_time);
        TextView tvContent = helper.itemView.findViewById(R.id.tv_content);

        tvTime.setText(item.getBEGUZ() + "-" + item.getENDUZ());
        tvContent.setText(item.getAWART());
    }

    private void bindRecord(BaseViewHolder helper, CheckRecord item) {

        TextView tvTime = helper.itemView.findViewById(R.id.tv_time);
        TextView tvContent = helper.itemView.findViewById(R.id.tv_content);
        tvTime.setText(item.getEntryDT());
        tvContent.setText(item.getSignInName());


    }
}
